package com.clive.service.impl;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import com.clive.bean.Dishes;
import com.clive.dao.DishesDao;
import com.clive.dao.impl.DishesDaoImpl;
import com.clive.service.DishesService;
import com.clive.vo.DishesVo;

public class DishesServiceimpl implements DishesService{
	private DishesDao dishesDao = new DishesDaoImpl();
	public boolean addDishes(Dishes dishes) {
		Date date = new Date();
		dishes.setBuyCount(0);
		dishes.setCreated(date);
		dishes.setUpdated(date);
		dishes.setPicPath("ddd.jpg");
		dishes.setStatus(1);
		int i = dishesDao.addDishes(dishes);
		if (i<=0) {
			return false;
		}
		return true;
	}

	public boolean updateDishes(Dishes dishes) {
		//加上修改事件
		Date date = new Date();
		dishes.setUpdated(date);
		int i = dishesDao.updateDishes(dishes);
		if (i<=0) {
			return false;
		}
		return true;
	}

	public boolean deleteDishesById(Integer dishesId) {
		int i = dishesDao.deleteDishesById(dishesId);
		if (i<=0) {
			return false;
		}
		return true;
	}

	public boolean deleteDishesByIds(List<Integer> ids) {
		// TODO Auto-generated method stub
		return false;
	}

	public DishesVo findDishesByCurrentPage(Integer currentPage, Integer limit) {
		DishesVo vo = new DishesVo();
		//得到总记录条数
		int dishesTotal = dishesDao.findDishesByCount();
		vo.setDishesTotal(dishesTotal);
		//进行分页操作
		List<Dishes> list = dishesDao.findDishesByCurrentPage((currentPage-1)*limit, limit);
		vo.setDishess(list);
		return vo;
	}

	public List<Dishes> findDishesByName(String dishName) {
		// TODO Auto-generated method stub
		return null;
	}

	public List<Dishes> findDishesByCategoryId(Integer dishesCategoryId) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Dishes findDishesById(Integer dishId) {
		Dishes dishes = dishesDao.findDishesById(dishId);
		return dishes;
	}
	
	
}
